quartz: remove maximized state when the window position/size is changed
authorChristoph Reiter <reiter.christoph@gmail.com>
Mon, 20 Jul 2015 08:40:35 +0000 (10:40 +0200)
committerChristoph Reiter <creiter@src.gnome.org>
Thu, 23 Jul 2015 11:20:05 +0000 (13:20 +0200)
So a window can be maximized/zoomed again after being moved away from
its maximized position. This makes the zoom button on non-CSD windows
work as before.

gdk/quartz/GdkQuartzNSWindow.c
gdk/quartz/GdkQuartzNSWindow.h

index c6dc77c29dabe8c3ae8d5551eacc67e638474fd3..87206ca990d7dd9a3ed70205cc707b1ac135c63a 100644 (file)
   GdkWindow *window = [[self contentView] gdkWindow];
   GdkEvent *event;
 
+  GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
+  gboolean maximized = gdk_window_get_state (window) & GDK_WINDOW_STATE_MAXIMIZED;
+
+  /* In case the window is changed when maximized remove the maximized state */
+  if (maximized && !inMaximizeTransition && !NSEqualRects (lastMaximizedFrame, [self frame]))
+    {
+      gdk_synthesize_window_state (window,
+                                   GDK_WINDOW_STATE_MAXIMIZED,
+                                   0);
+    }
+
   _gdk_quartz_window_update_position (window);
 
   /* Synthesize a configure event */
   NSRect content_rect = [self contentRectForFrameRect:[self frame]];
   GdkWindow *window = [[self contentView] gdkWindow];
   GdkEvent *event;
+  GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (window->impl);
+  gboolean maximized = gdk_window_get_state (window) & GDK_WINDOW_STATE_MAXIMIZED;
+
+  /* see same in windowDidMove */
+  if (maximized && !inMaximizeTransition && !NSEqualRects (lastMaximizedFrame, [self frame]))
+    {
+      gdk_synthesize_window_state (window,
+                                   GDK_WINDOW_STATE_MAXIMIZED,
+                                   0);
+    }
 
   window->width = content_rect.size.width;
   window->height = content_rect.size.height;
@@ -713,6 +734,7 @@ update_context_from_dragging_info (id <NSDraggingInfo> sender)
 
   if (maximized)
     {
+      lastMaximizedFrame = newFrame;
       gdk_synthesize_window_state (window,
                                    GDK_WINDOW_STATE_MAXIMIZED,
                                    0);
@@ -725,7 +747,13 @@ update_context_from_dragging_info (id <NSDraggingInfo> sender)
                                    GDK_WINDOW_STATE_MAXIMIZED);
     }
 
+  inMaximizeTransition = YES;
   return YES;
 }
 
+-(void)windowDidEndLiveResize:(NSNotification *)aNotification
+{
+  inMaximizeTransition = NO;
+}
+
 @end
index 792ea24f48347af0dcf1bc53be71048f94f5d2c6..a274ee9b2a702d85e44e5f46addeb98ca0e5a4f8 100644 (file)
@@ -34,6 +34,8 @@
   NSRect  initialResizeFrame;
 
   NSRect  lastUnmaximizedFrame;
+  NSRect  lastMaximizedFrame;
+  BOOL    inMaximizeTransition;
 }
 
 -(BOOL)isInMove;